<?php
formbody();

// ----------------------- Functions --------------------------------------------------------------------------------------------

function formbody() {

    global $link;
    $customerid = $_SESSION['customerid'];                  

    // initialize variables.

    echo '<form name="" action=' . $link . ' method="post">';
    echo '<div class="content_frame2">';
    echo '<div id="block">';
    echo 'Sprachen ausw&auml;hlen:<br /><br />';
    $sql = "SELECT * FROM settings where customerid = ". $customerid;
    $sql3 = "SELECT distinct learn FROM langpairs_german order by langpairid";
    $sql4 = "SELECT distinct can FROM langpairs_german order by langpairid";

    // DB Query
    $db_res = mysql_query( $sql );
    if ( ! $db_res ) { die('Error query1: ' . mysql_error()); }
    $db_sel3 = mysql_query( $sql3 );
    if ( ! $db_sel3 ) { die('Error query2: ' . mysql_error()); }
    $db_sel4 = mysql_query( $sql4 );
    if ( ! $db_sel4 ) { die('Error query3: ' . mysql_error()); }

    // Show custoomer data
    while ($row = mysql_fetch_array( $db_res, MYSQL_ASSOC)) {
    $langpair = $row['langpair'];
    $new = $row['learnde'];
    if ( $new == '' ) { $new = '-'; }
    $old = $row['cande'];
    if ( $old == '' ) { $old = '-'; }

	    echo '<div class="left2">Ich m&ouml;chte lernen:</div>';
        echo '<div class="marginbottom"><b>'. $new . '</b></div>';
        // change new language
        echo '<div class="marginleft4">';
        echo '<select class="fixwidth" name="change_new" onchange=submit()>';
        echo '<option value="" >&auml;ndern?&nbsp;</option>';
        while ($row = mysql_fetch_array( $db_sel3, MYSQL_ASSOC)) {
        if ( $row['learn'] <> $new )
        { echo '<option value="'. $row['learn'] . '" >'. $row['learn'] . '</option>'; }
        }
        echo '</select>';
        echo '</div>';

        echo '<br />';
        echo '<br />';

        echo '<div class="left2">Ausgangssprache:</div>';
        echo '<div class="marginbottom"><b>'. $old . '</b></div>';
        // change old language
        echo '<div class="marginleft4">';
        echo '<select class="fixwidth" name="change_old" onchange=submit()>';
        echo '<option value="" >&auml;ndern?&nbsp;</option>';
        while ($row = mysql_fetch_array( $db_sel4, MYSQL_ASSOC)) {
        if ( $row['can'] <> $old )
        { echo '<option value="'. $row['can'] . '" >'. $row['can'] . '</option>'; }
        }
        echo '</select>';
        echo '<br /></div><br />';
      //  echo "<br /><div><input type='image' src='images/buttons/speichern.gif' name='next' alt='Speichern' title=' Speichern ' /></div>";
        
    }                                           
        echo '</div>';
        echo '</div>';
    echo '</form>';
}
?>